package com.zcaxer.way.data

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update

@Dao
interface BuildingDao {

    @Query("SELECT * from BUILDING_TABLE ORDER BY ID")
    fun getBuildings(): LiveData<List<Building>>

    @Query("SELECT * from BUILDING_TABLE  WHERE ID<5 ORDER BY ID")
    fun getProducers(): LiveData<List<Building>>

    @Update
    suspend fun updateBuilding(building: Building)

    @Insert
    fun insert(building: Building)

    @Query("UPDATE building_table SET reserve=:reserve WHERE ID=:id")
    suspend fun updateReserve(reserve: Int,id: Int)

    @Query("UPDATE building_table SET workers=:workers WHERE ID=:id")
    suspend fun updateWorkers(workers: Int,id: Int)

    @Query("UPDATE building_table SET target=:target WHERE ID=:id")
    suspend fun updateTarget(target: Int,id: Int)

    @Query("UPDATE building_table SET workersNeed=:workersNeed WHERE ID=:id")
    suspend fun updateWorkersNeed(workersNeed: Int,id: Int)

}